﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebSEClassLibrary;

namespace WebSE
{
    public partial class Act1 : System.Web.UI.Page
    {
        private ActPage actPage;

        protected void Page_Load(object sender, EventArgs e)
        {
            actPage = (ActPage)Session["currentPage"];
            problem.Text = actPage.Problem;
            chA.Text = actPage.Choices[0];
            chB.Text = actPage.Choices[1];
            chC.Text = actPage.Choices[2];
            chD.Text = actPage.Choices[3];

            //用户答案
            if (!Page.IsPostBack)
            {
                if (actPage.UserChsAns == null) return;
                switch (actPage.UserChsAns[0])
                {
                    case 0:
                        chA.Checked = true;
                        break;
                    case 1:
                        chB.Checked = true;
                        break;
                    case 2:
                        chC.Checked = true;
                        break;
                    case 3:
                        chD.Checked = true;
                        break;
                }
            }
        }

        protected void submit(object sender, EventArgs e)
        {
            explain.Text = "";
            //提交时记录用户答案
            if (chA.Checked)
            {
                actPage.UserChsAns[0] = 0;
                explain.Text = actPage.ExplainChs[0];
            }
            else if (chB.Checked)
            {
                actPage.UserChsAns[0] = 1;
                explain.Text = actPage.ExplainChs[1];
            }
            else if (chC.Checked)
            {
                actPage.UserChsAns[0] = 2;
                explain.Text = actPage.ExplainChs[2];
            }
            else if (chD.Checked)
            {
                actPage.UserChsAns[0] = 3;
                explain.Text = actPage.ExplainChs[3];
            }
            else explain.Text = "请选择答案";
        }

        protected void check(object sender, EventArgs e)
        {
            explain.Text = "";
            explain.Text = actPage.ExplainChs[actPage.ChsAns[0]];
        }
    }
}
